package com.yanqu.road.server.cmd;

import com.yanqu.road.connect.AgentServerLinkControl;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.player.Player;
import com.yanqu.road.player.PlayerControl;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.YanQuMessageUtils;
import io.netty.channel.ChannelHandlerContext;

@Cmd(code = Protocol.A_NEW_YEAR_BAG_SYNC_NOTICE, desc = "新春红包同步公告")
public class NewYearBagSyncNoticeCmd implements Command {

    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {
        for (Player player : PlayerControl.getOnlinePlayerMap().values()) {
            YanQuMessage message = YanQuMessageUtils.buildMessageByte(ClientProtocol.U_NEW_YEAR_BAG_SYNC_NOTICE, packet.getBytes());
            message.setPlayerId(player.getPlayerId());
            message.setLen(packet.getLen());
            AgentServerLinkControl.routeClient(message);
        }
    }
}
